<template>
	<z-paging ref="paging" v-model="list" @query="getList">
		<template v-if="current === 0">
			<view class="d-p-l-30 d-p-r-30">
				<view class="d-list-box d-m-t-20 d-p-20 d-flex d-col-top flex-column">
					<!-- <view class="d-font-34 d-white">
						外馆游泳票
					</view> -->
					<view class="d-flex">
						<u-image :src="picture" width="148rpx" height="148rpx" shape="circle"></u-image>

						<view class="d-m-l-20 d-flex-1">
							<view class="d-m-t-60 d-font-30 d-red">
								<text class="d-font-24">￥</text>
								<text class="d-bold">{{cardarr.ticketprice}}</text>
							</view>
							<view class="d-font-30 u-line-1 d-white">票名：{{cardarr.consumetype}}{{cardarr.chargetype}}</view>
							<view class="d-font-30 u-line-1 d-xuxian"></view>
							<view class="d-font-30 u-line-1 d-white">场馆：{{cardarr.orgName}}</view>
							<!-- <view class="d-flex d-m-t-18">
								<view class="d-tag d-flex">{{ item.specify }}</view>
							</view>
							<view class="d-font-24 d-be d-m-t-20">{{ item.tip }}</view>
							<view class="d-font-24 d-be d-m-t-20" style="margin-left: 47rpx;">{{ item.text }}</view> -->

						</view>
					</view>

				</view>
				
				<view class="qline">
					<view class="l1"></view>
					<view class="l1 l2"></view>
				</view>
				<view class="d-p-t-60">
					<view class="d-qrd">
						<view class="qcard">
							<view class="q1"></view>
							<view class="q1 q2"></view>
						</view>
						<view class="d-text-center d-p-t-60 d-main">使用时请出示此二维码</view>
						<view class="d-flex d-row-center d-m-t-15">
							<!-- <u-image :src="$demo" width="370rpx" height="370rpx"></u-image> -->
							<uqrcode :ref="'uqrcode' + index" :canvas-id="'qrcode' + index" size="185" :value="concatenatedTimestamp" :options="{ margin: 10 }"></uqrcode>
						</view>
						<view class="d-main d-font-32 d-text-center d-m-t-30">{{ cardno }}</view>
						<view class="d-text-center d-99 d-font-22">为保障用户权益，二维码有效期为1分钟，请尽快展示核销</view>
					</view>
				</view>
			</view>
		</template>
		<customer-Kefu ></customer-Kefu>
	</z-paging>
</template>

<script>
	import {
		usercardDetail,
		ticket
	} from '@/common/api';
	import customerKefu from '../../components/customerKefu/customerKefu.vue';
	export default {
		components: {
			customerKefu
		},
		data() {
			return {
				current: 0,
				list: [],
				picture: '../../static/qita/icon12.png',
				index:0,
				cardType:"",
				cardno:'',
				cardarr:{},
				concatenatedTimestamp: '',
				timer: null,
			};
		},
		onLoad(e) {
			this.cardType = e.product_type,
			this.cardno =  e.ticketno
			let that = this;
			that.timer = null;
			// 当前时间的10位时间戳
			var currentTimestamp = Math.floor(new Date().getTime() / 1000);
			// 拼接时间戳
			var concatenatedTimestamp = this.cardno + '&' + currentTimestamp;
			this.concatenatedTimestamp = concatenatedTimestamp
			
			console.log(concatenatedTimestamp);
		},
		onShow() {
			let that = this;
			that.timer = null;
			clearInterval(that.timer);
			that.timer = setInterval(() => {
				// 当前时间的10位时间戳
				var currentTimestamp = Math.floor(new Date().getTime() / 1000);
		
				// 拼接时间戳
				var concatenatedTimestamp = this.cardno + '&' + currentTimestamp;
				this.concatenatedTimestamp = concatenatedTimestamp
		
				console.log(concatenatedTimestamp);
			}, 60000);
		},
		onUnload() {
			let that = this;
			clearInterval(that.timer);
			that.timer = null;
		},
		onHide() {
			let that = this;
			clearInterval(that.timer);
			that.timer = null;
		},
		methods: {
			async getList(page, limit) {
				usercardDetail({
						venue_id: uni.getStorageSync('venue_id'),
						cardType:this.cardType,
						cardNo:this.cardno,
					})
					.then(res => {
						console.log(res, '222')
						this.cardarr = res.card
					})
					.catch(err => {
						this.$ref.paging.complete(false);
					});
			},
		}
	};
</script>

<style lang="scss" scoped>
	.d-list-box {
		box-shadow: 0rpx 13rpx 57rpx 0rpx rgba(8, 73, 162, 0.11);
		background: rgb(6, 164, 255);
		border-radius: 10rpx;
	}

	.d-list-box1 {
		box-shadow: 0rpx 13rpx 57rpx 0rpx rgba(8, 73, 162, 0.11);
		background: rgb(48, 182, 134);
		border-radius: 10rpx;
	}

	.d-list-box2 {
		box-shadow: 0rpx 13rpx 57rpx 0rpx rgba(8, 73, 162, 0.11);
		background: rgb(253, 168, 92);
		border-radius: 10rpx;
	}

	.d-tag {
		background: #f3f3f3;
		border-radius: 4rpx;
		height: 36rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #333333;
		padding: 0 18rpx;
	}

	.d-be {
		color: #bebebe;
	}

	.d-red {
		color: #ffffff;
		margin-top: 10rpx !important;
	}

	.d-white {
		color: #ffffff;
		margin-top: 10rpx !important;
	}

	.d-xuxian {
		width: 100%;
		height: 1rpx;
		border-bottom: 1px dashed white;
		margin-top: 10rpx;
	}

	.d-bold {
		font-weight: bold;

	}
	
	.qline {
		position: relative;
		.l1 {
			width: 20rpx;
			height: 60rpx;
			background: #dce0fd;
			border-radius: 10rpx;
			position: absolute;
			left: 130rpx;
			bottom: -60rpx;
		}
		.l2 {
			left: auto;
			right: 130rpx;
		}
	}
	
	.d-qrd {
		width: 626rpx;
		min-height: 660rpx;
		background: #ffffff;
		box-shadow: 0rpx 13rpx 57rpx 0rpx rgba(8, 73, 162, 0.11);
		border-radius: 10rpx;
		margin: -22rpx auto 0;
	}
	
	.qcard {
		position: relative;
		.q1 {
			width: 22rpx;
			height: 22rpx;
			background: #ffffff;
			border: 4rpx solid #575c86;
			border-radius: 50%;
			box-sizing: border-box;
			position: absolute;
			left: 99rpx;
		}
		.q2 {
			left: auto;
			right: 99rpx;
		}
	}
	.d-main {
		color: #59a0ff;
	}
	.d-99 {
		color: #999;
	}
	
	.d-filter {
		filter: grayscale(100%);
	}
</style>